<template>
    <div>
       <table class="table">
          <tbody>
            <tr>
             <td>项目名称</td>
             <td><input type="text" v-model="date.shanName"></td>
          </tr>
          <tr>
             <td>项目编号</td>
             <td><input type="text" v-model="date.shanBian"></td>
          </tr>
          <tr>
             <td>服务时长</td>
             <td><input type="text" v-model="date.shanShi"></td>
          </tr>
          <tr>
             <td>服务人数</td>
             <td><input type="text" v-model="date.shanRen"></td>
          </tr>
          <tr>
             <td>佣金</td>
             <td><input type="text" v-model="date.shanYong"></td>
          </tr>
          <tr>
             <td>项目说明</td>
             <td><input type="text" v-model="date.shanShuo"></td>
          </tr>
          <tr>
             <td></td>
             <td><input type="button" value="添加" @click="postdata"></td>
          </tr>
          </tbody>
       </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref , onMounted } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

const date = ref(
{
  "shanId": 0,
  "shanName": "",
  "shanBian": "",
  "shanShi": "",
  "shanRen": "",
  "shanYong": "",
  "shanShuo": "",
  "shanStart": 0,
  "shanDele": 0
}
)

const postdata=()=>{
   if(date.value.shanName==""){
   alert("项目名称不能为空")
   return;
   }
   if(date.value.shanBian==""){
   alert("项目编号不能为空")
   return;
   }
   if(date.value.shanShi==""){
   alert("服务时长不能为空")
   return;
   }
   if(date.value.shanRen==""){
   alert("服务人数不能为空")
   }
   if(date.value.shanYong==""){
   alert("佣金不能为空")
   return;
   }
   if(date.value.shanShuo==""){
   alert("项目说明不能为空")
   return;
   }
    axios.post("/api/Shan/AddAsyncss",date.value).then(res=>{
        if(res.data>0){
        alert("添加成功")
        router.push("/Lists");
        }
        else{
        alert("添加失败")
        }
    })
}



</script>

<style scoped>

</style>